home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Contributions / Haage_&_Partner / Storm-Projects / NDKExamples1 / intuition / frameidemo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-16  |  3.4 KB  |  141 lines

  1. /*
  2.  * frameidemo.c - shows frame types from frameiclass
  3.  *
  4.  * (c) Copyright 1992-1996 Amiga International, Inc. All rights reserved.
  5.  *
  6.  * This software is provided as-is and is subject to change; no warranties
  7.  * are made.  All use is at your own risk.  No liability or responsibility
  8.  * is assumed.
  9.  *
  10.  * For V39, the boopsi frameiclass imageclass has been extended to
  11.  * support a bunch of system-standard frames.  This demo shows
  12.  * the default frame, the standard button frame, the ridge, and
  13.  * the icon drop box, and shows the indentation feature.
  14.  */
  15.  
  16. /*------------------------------------------------------------------------*/
  17.  
  18. #include <intuition/intuitionbase.h>
  19. #include <intuition/imageclass.h>
  20. #include <graphics/gfxbase.h>
  21.  
  22. #include <clib/intuition_protos.h>
  23. #include <clib/exec_protos.h>
  24.  
  25. #include <stdlib.h>
  26.  
  27. /*------------------------------------------------------------------------*/
  28.  
  29. void bail_out(int code);
  30.  
  31. /*------------------------------------------------------------------------*/
  32.  
  33. struct NewWindow newwin =
  34.     {
  35.     0,0,        /*  LeftEdge, TopEdge */
  36.     600,200,            /*  Width, Height */
  37.     (UBYTE)-1, (UBYTE)-1,               /*  DetailPen, BlockPen */
  38.     IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW,    /*  IDCMPFlags */
  39.     WFLG_DRAGBAR | WFLG_SIZEGADGET | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET |
  40.     WFLG_ACTIVATE|WFLG_SMART_REFRESH,    /* Flags */
  41.     NULL,        /*  FirstGadget */
  42.     NULL,        /*  CheckMark */
  43.     (UBYTE *) "FrameIClass Demo",    /*  Title */
  44.     NULL,        /*  Screen */
  45.     NULL,        /*  BitMap */
  46.     100,50,        /*  MinWidth, MinHeight */
  47.     640,200,        /*  MaxWidth, MaxHeight */
  48.     WBENCHSCREEN,    /*  Type */
  49.     };
  50.  
  51. /*------------------------------------------------------------------------*/
  52.  
  53. struct Library *GfxBase;
  54. struct Library *IntuitionBase;
  55. struct Window *win;
  56. struct Image *frame;
  57.  
  58. /*------------------------------------------------------------------------*/
  59.  
  60. void main(void)
  61.     {
  62.     BOOL terminated;
  63.     struct IntuiMessage *imsg;
  64.     long frametype, recessed;
  65.  
  66.     terminated = FALSE;
  67.     win = NULL;
  68.  
  69.     if (!(GfxBase = 
  70.     OpenLibrary("graphics.library",39L)))
  71.     bail_out(20);
  72.  
  73.     if (!(IntuitionBase = 
  74.     OpenLibrary("intuition.library",39L)))
  75.     bail_out(20);
  76.  
  77.     if (!(win = OpenWindow(&newwin)))
  78.     bail_out(20);
  79.  
  80.     for ( recessed = 0; recessed <= 1; recessed++ )
  81.     {
  82.     for ( frametype = 0; frametype <= 3; frametype++ )
  83.     {
  84.         if ( !( frame = NewObject( NULL, "frameiclass",
  85.         IA_FrameType, frametype,
  86.         IA_Recessed, recessed,
  87.         IA_Width, 80,
  88.         IA_Height, 20,
  89.         TAG_DONE ) ) )
  90.         bail_out(20);
  91.  
  92.         DrawImage( win->RPort, frame, 20 + frametype*100,
  93.         win->WScreen->Font->ta_YSize + 12 + recessed*30 );
  94.     }
  95.     }
  96.     while (!terminated)
  97.     {
  98.     Wait (1 << win->UserPort->mp_SigBit);
  99.     while (imsg = (struct IntuiMessage *) GetMsg(win->UserPort))
  100.         {
  101.         if (imsg->Class == IDCMP_CLOSEWINDOW)
  102.         terminated = TRUE;
  103.         else if (imsg->Class == IDCMP_REFRESHWINDOW)
  104.         {
  105.         BeginRefresh(win);
  106.         EndRefresh(win,TRUE);
  107.         }
  108.         ReplyMsg((struct Message *) imsg);
  109.         }
  110.     }
  111.     bail_out(0);
  112.     }
  113.  
  114.  
  115. /*------------------------------------------------------------------------*/
  116.  
  117. /*/ bail_out()
  118.  *
  119.  * Close any allocated or opened stuff.
  120.  */
  121.  
  122. void bail_out(int code)
  123.     {
  124.     if (frame)
  125.     DisposeObject(frame);
  126.  
  127.     if (win)
  128.     CloseWindow(win);
  129.  
  130.     if (IntuitionBase)
  131.     CloseLibrary(IntuitionBase);
  132.  
  133.     if (GfxBase)
  134.     CloseLibrary(GfxBase);
  135.  
  136.     exit(code);
  137.     }
  138.  
  139.  
  140. /*------------------------------------------------------------------------*/
  141.